﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.ajax
{
    public partial class inventory : System.Web.UI.Page
    {
        Maticsoft.BLL.Inventory dbll = new Maticsoft.BLL.Inventory();
        Maticsoft.BLL.InventoryClass dbll2 = new Maticsoft.BLL.InventoryClass();
        Maticsoft222.BLL.sqlexec exbll = new Maticsoft222.BLL.sqlexec();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["action"]) && Request["action"] == "upprice")
                {
                    Maticsoft.Model.Inventory mod = dbll.GetModel(Convert.ToInt32(Request["id"]));
                    mod.buyvalue = Request["buyvalue"];
                    mod.dictionarycode = Request["parentlist"];
                    exbll.setturestatus(mod.dictionarycode);
                    Response.Write((dbll.Update(mod) ? "1" : "0"));
                }
                else if (!string.IsNullOrEmpty(Request["action"]) && Request["action"] == "getmodel")
                {
                    List<Maticsoft.Model.Inventory> mod = dbll.GetModelList("cInvCode='" + Request["cInvCode"] + "'");
                    Response.Write(JsonConvert.SerializeObject(mod.Count > 0 ? mod[0] : null));
                }
                else
                {
                    Response.Write(string.Format("{0}", (dbll.GetInventoryList(Request["id"], "bSale", "01,02") && dbll2.GetInventoryClassList(Request["id"], "01,02")) ? "1" : "0"));//同步属性为销售的面料类型同步原材料和辅助材料
                }
            }
        }
    }
}